<%--<%@ page language="java" contentType="text/html; charset=UTF-8"--%>
<%--		 pageEncoding="UTF-8"%>--%>
<%--<!DOCTYPE html>--%>
<%--<html>--%>
<%--<head>--%>
<%--	<meta charset="utf-8">--%>
<%--	<title>修改密码</title>--%>
<%--	<meta name="renderer" content="webkit">--%>
<%--	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">--%>
<%--	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">--%>
<%--	<meta name="apple-mobile-web-app-status-bar-style" content="black">--%>
<%--	<meta name="apple-mobile-web-app-capable" content="yes">--%>
<%--	<meta name="format-detection" content="telephone=no">--%>
<%--	<link rel="stylesheet" href="${pageContext.request.contextPath}/layui/layui/css/layui.css" media="all" />--%>
<%--	<link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/public.css" media="all" />--%>
<%--</head>--%>
<%--<body class="childrenBody">--%>
<%--<form class="layui-form layui-row changePwd">--%>
<%--	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">--%>
<%--		<div class="layui-input-block layui-red pwdTips">默认密码为“123”，新密码必须两次输入一致才能提交</div>--%>
<%--		<div class="layui-form-item">--%>
<%--			<input type="text" name="eNumber" value="${sessionScope.login.eNumber}" hidden>--%>
<%--			<label class="layui-form-label">用户名</label>--%>
<%--			<div class="layui-input-block">--%>
<%--				<input type="text" name="eName" value="${sessionScope.login.eName}" disabled class="layui-input layui-disabled">--%>
<%--			</div>--%>
<%--		</div>--%>
<%--		<div class="layui-form-item">--%>
<%--			<label class="layui-form-label">旧密码</label>--%>
<%--			<div class="layui-input-block">--%>
<%--				<input type="password" name="oldpassword" value="" placeholder="请输入新密码" lay-verify="required|newPwd" id="oldPwd" class="layui-input pwd">--%>
<%--			</div>--%>
<%--		</div>--%>
<%--		<div class="layui-form-item">--%>
<%--			<label class="layui-form-label">新密码</label>--%>
<%--			<div class="layui-input-block">--%>
<%--				<input type="password" name="password" value="" placeholder="请输入新密码" lay-verify="required|newPwd"  class="layui-input pwd">--%>
<%--			</div>--%>
<%--		</div>--%>
<%--		<div class="layui-form-item">--%>
<%--			<label class="layui-form-label">确认密码</label>--%>
<%--			<div class="layui-input-block">--%>
<%--				<input type="password" name="qrpassword" value="" placeholder="请确认密码" lay-verify="required|confirmPwd" class="layui-input pwd">--%>
<%--			</div>--%>
<%--		</div>--%>
<%--		<div class="layui-form-item">--%>
<%--			<div class="layui-input-block">--%>
<%--				<button class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>--%>
<%--				<button type="reset" class="layui-btn layui-btn-primary">重置</button>--%>
<%--			</div>--%>
<%--		</div>--%>
<%--	</div>--%>
<%--</form>--%>
<%--<script type="text/javascript" src="${pageContext.request.contextPath}/layui/layui/layui.js"></script>--%>
<%--<script type="text/javascript" src="user.js"></script>--%>

<%--<script>--%>

<%--	layui.use([ 'form', 'jquery','layer'], function() {--%>
<%--		let form = layui.form;--%>
<%--		let $ = layui.jquery;--%>
<%--		let layer = layui.layer;--%>
<%--		//监听提交--%>
<%--		form.on('submit(changePwd)', function (data) {--%>
<%--				alert(data);--%>
<%--				$.ajax({--%>
<%--					url:"${pageContext.request.contextPath}/password?oldpassword="+data.field.oldpassword+"&eNumber="+data.field.eNumber+"&password="+data.field.qrpassword,--%>
<%--					dataType: 'json',--%>
<%--					success: function(result) {--%>
<%--						if (result.code == 200) {--%>
<%--							layer.msg(result.msg, {--%>
<%--								icon: 1,--%>
<%--								time: 1000--%>
<%--							});--%>
<%--						} else {--%>
<%--							layer.msg(result.msg, {--%>
<%--								icon: 2,--%>
<%--								time: 1000--%>
<%--							});--%>
<%--						}--%>
<%--					}--%>
<%--				})--%>
<%--			})--%>
<%--	});--%>
<%--</script>--%>
<%--</body>--%>
<%--</html>--%>
<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2021/11/28
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
	<title>修改密码</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui/layui/css/layui.css">
	<script type="text/javascript" src="${pageContext.request.contextPath}/layui/layui/layui.js"></script>
	<style>
		/*解决普通复选框无上边框问题*/
		.laytable-cell-1-0-0 .layui-icon {
			margin-top: 5px !important;
		}

		/*解决横条复选框无上边框问题*/
		.layui-table-view .layui-form-checkbox {
			margin-top: 0px !important;
		}

		body {
			margin: 10px 10px;
		}
	</style>
</head>
<body>
<div style="font-size:24px;color: cadetblue;font-weight: bolder;position: relative;left: 27%;top: 136px;width: 100px;height: 30px;">
	密码修改
</div>
<form class="layui-form" style="margin: 190px 437px;font-size: 17px;" id="form">
	<input type="text" id="eNumber" name="eNumber" value="${sessionScope.login.eNumber}" hidden=/>
	<div class="layui-form-item">
		<label class="layui-form-label" style="width: 120px">用户名：</label>
		<div class="layui-input-inline">
			<input type="text" name="eName" id="eName" lay-verify="pass" value="${sessionScope.login.eName}"
				   autocomplete="off" class="layui-input layui-form-danger" disabled>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label" style="width: 120px">旧密码：</label>
		<div class="layui-input-inline">
			<input type="password" name="e_password" id="e_password" lay-verify="pass" placeholder="请输入旧密码"
				   autocomplete="off" class="layui-input layui-form-danger">
		</div>
		<div style="display: none" class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label" style="width: 120px">新密码：</label>
		<div class="layui-input-inline">
			<input type="password" name="new_password" id="new_password" lay-verify="pass" placeholder="请输入新密码"
				   autocomplete="off" class="layui-input">
		</div>
		<div style="display: none" class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label" style="width: 120px">请确认新密码：</label>
		<div class="layui-input-inline">
			<input type="password" name="again_password" id="again_password" lay-verify="pass" placeholder="请再次输入密码"
				   autocomplete="off" class="layui-input">
		</div>
		<div style="display: none" class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
	</div>
	<div class="layui-form-item" style="text-align: center">
		<button class="layui-btn" type="button" lay-submit="" lay-filter="formDemo" id="commit">确定修改</button>
	</div>
</form>

<script>
	layui.use(['table', 'jquery', 'form'], function () {
		var table = layui.table;
		var $ = layui.jquery;
		var form = layui.form;
		//自定义验证规则
		//自定义验证规则
		form.verify({
			pass: [
				/^[\S]{6,12}$/
				, '密码必须6到12位，且不能出现空格'
			]
		});
		//校验输入的新密码要跟再次输入的密码一样
		$("#form #again_password").blur(function () {
			if ($("#new_password").val() != $("#again_password").val()) {
				layer.msg("两次输入的密码不一样", {icon: 5})
			}
		})

		//监听提交
		$("#commit").click(function () {
			if ($("#new_password").val() != $("#again_password").val()) {
				layer.msg("两次输入的密码不一样", {icon: 5})
			} else {
				$.ajax({
					url: '${pageContext.request.contextPath}/password',
					data: {eNumber:$("#eNumber").val(),eName:$("#eName").val(),e_password: $("#e_password").val(), new_password: $("#new_password").val()},
					dataType: "json",
					type: 'post',
					success: function (result) {
						if (result.code === 200) {
							layer.msg(result.msg, {icon: 1})
						} else {
							layer.msg(result.msg, {icon: 5})
						}
						//表单清空
						$("#form")[0].reset();
					}
				})
			}
		})
	});
</script>
</body>
</html>
